home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE6 / PD / PDF / GuiLib / Wimp / h / GuiWimpWindow < prev   
Text File  |  2003-02-14  |  4KB  |  102 lines

  1. //--------------------------------------------------------------------------
  2. //
  3. //   Copyright (c) 2002, Colin Granville
  4. //
  5. //   All rights reserved.
  6. //
  7. //   Redistribution and use in source and binary forms, with or
  8. //   without modification, are permitted provided that the following 
  9. //   conditions are met:
  10. //
  11. //      * Redistributions of source code must retain the above copyright 
  12. //        notice, this list of conditions and the following disclaimer.
  13. //
  14. //      * Redistributions in binary form must reproduce the above 
  15. //        copyright notice, this list of conditions and the following 
  16. //        disclaimer in the documentation and/or other materials 
  17. //        provided with the distribution.
  18. //
  19. //      * The name Colin Granville may not be used to endorse or promote 
  20. //        products derived from this software without specific prior 
  21. //        written permission.
  22. //
  23. //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  24. //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  25. //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  26. //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  27. //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  28. //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  29. //   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  30. //   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  31. //   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  32. //   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  33. //   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
  34. //   OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //--------------------------------------------------------------------------
  37.  
  38. #ifndef GuiWimpWindow_h
  39. #define GuiWimpWindow_h
  40.  
  41. class GuiWindowPositionBlock
  42. {
  43.   public:
  44.     int      windowHandle;   
  45.     GuiBBox  visibleArea;
  46.     int      xscroll;
  47.     int      yscroll;
  48.     
  49.     // conversion routines
  50.     int      xToScreen(int x) const       {return x-xscroll+visibleArea.xmin;}
  51.     int      yToScreen(int y) const       {return y-yscroll+visibleArea.ymax;}
  52.     int      xToWorkarea(int x) const     {return x+xscroll-visibleArea.xmin;}
  53.     int      yToWorkarea(int y) const     {return y+yscroll-visibleArea.ymax;}
  54.     int      windowTopToWorkarea() const  {return yscroll;}
  55.     int      windowLeftToWorkarea() const {return xscroll;}
  56.     GuiBBox  toScreen(const GuiBBox &in) const;
  57.     GuiBBox  toWorkarea(const GuiBBox &in) const;
  58. };
  59.  
  60. class GuiRedrawWindowBlock : public GuiWindowPositionBlock
  61. {
  62.   public:
  63.     GuiBBox redrawArea;
  64. };
  65.  
  66. class GuiGetWindowStateBlock : public GuiWindowPositionBlock
  67. {
  68.   public:
  69.     int          behind;
  70.     unsigned int flags;
  71.     int          parent;
  72.     int          linkFlags;
  73. };
  74.  
  75. typedef GuiGetWindowStateBlock  GuiOpenWindowBlock;
  76.  
  77. //**************************************************************************
  78. //   inlines
  79. //**************************************************************************
  80.  
  81. inline GuiBBox GuiWindowPositionBlock::toScreen(const GuiBBox &in) const
  82. {
  83.     GuiBBox out;
  84.     out.xmin=xToScreen(in.xmin);
  85.     out.xmax=xToScreen(in.xmax);
  86.     out.ymin=yToScreen(in.ymin);
  87.     out.ymax=yToScreen(in.ymax);
  88.     return out;
  89. }
  90.  
  91. inline GuiBBox GuiWindowPositionBlock::toWorkarea(const GuiBBox &in) const
  92. {
  93.     GuiBBox out;
  94.     out.xmin=xToWorkarea(in.xmin);
  95.     out.xmax=xToWorkarea(in.xmax);
  96.     out.ymin=yToWorkarea(in.ymin);
  97.     out.ymax=yToWorkarea(in.ymax);
  98.     return out;
  99. }
  100.  
  101. #endif
  102.